import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import store from'./store'
import router from './router/index'
import Axios from 'axios'

import echarts from "echarts";
Vue.prototype.$echarts = echarts;

Vue.config.productionTip = false

Vue.use(ElementUI)

Vue.filter('formatDate',function (str){
  let date=new Date(str)
  let y = date.getFullYear();
  let m = date.getMonth() + 1;
  m = m < 10 ? '0' + m : m;
  let d = date.getDate();
  d = d < 10 ? ('0' + d) : d;
  return y + '-' + m + '-' + d;
})

Vue.filter('formatTime',function (timeStr){
  let time=new Date(timeStr)
  let y = time.getFullYear();
  let m = time.getMonth() + 1;
  m = m < 10 ? '0' + m : m;
  let d = time.getDate();
  d = d < 10 ? ('0' + d) : d;
  let h=time.getHours();
  h=h<10?('0'+h):h;
  let min=time.getMinutes();
  min=min<10?('0'+min):min;

  return y + '-' + m + '-' + d+' '+h+':'+min;
})

new Vue({
  render: h => h(App),
  store,router
}).$mount('#app')



// Axios.interceptors.request.use(
//   config => {
//     if (localStorage.getItem("TOKEN")) {  // 判断是否存在token，如果存在的话，则每个http header都加上token
//       config.headers['TOKEN'] =localStorage.getItem("TOKEN")
//       console.log("token用啦");
//     }
//     console.log("没用");
//     return config;
//   },
//   err => {
//     console.log("有问题");
//     return Promise.reject(err);
//   });

// Axios.defaults.headers.common["TOKEN"] = localStorage.getItem("TOKEN")
// console.log("test"+localStorage.getItem("TOKEN"));

